package gui;

import java.util.Vector;

import model.Stack;
import service.Service;
import dao.Dao;

/**
 * @author Alexander Shidlovsky
 */
public class FinishedPanel extends TabledFilteringPanel {

	public FinishedPanel() {
		super();

		String[] columnNamesArray = { "Name", "Number of trays", "Start time",
				"Finish time" };

		for (int i = 0; i < columnNamesArray.length; i++) {
			columnNames.add(columnNamesArray[i]);
		}

		generateDataVector();

		setData(columnNames, data);

	}

	@Override
	protected void generateDataVector() {
		for (Stack x : Dao.getInstance().getFinished()) {
			Vector<Object> dataRow = new Vector<Object>();
			dataRow.add(x);
			dataRow.add(x.getNumberOfTrays());
			dataRow.add(Service.getInstance().displayTime(
					x.getTasks().get(0).getStartTime()));
			dataRow.add(Service.getInstance().displayTime(
					x.getTasks().get(x.getTasks().size() - 1).getFinishTime()));
			data.add(dataRow);
		}
	}

}
